//
//  AppDelegate.m
//  DingDongXiChe
//
//  Created by wtjr on 2017/11/15.
//  Copyright © 2017年 xieyingze. All rights reserved.
//

#import "AppDelegate.h"
#import "HomeController.h"
#import "DDRegAndLogController.h"
#import "AppHeader.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <MapKit/MapKit.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

+ (instancetype)shareIntacenDelegate {
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

- (void)setRootViewController:(UIViewController*)controller {
    UIWindow* window = self.window;
    
    UIViewController* oldController = window.rootViewController;
    UIView *anview = oldController.view;
    anview.alpha = 1.0f;
    window.rootViewController = controller;
    
    [window addSubview:anview];
    [anview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
    [UIView animateWithDuration:0.25 animations:^{
        anview.alpha = 0.0f;
    }completion:^(BOOL finished) {
        [anview removeFromSuperview];
    }];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = kCOLOR_white;
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[UnityTool isLogin] ? [HomeController new]: [DDRegAndLogController new]];
    [self.window makeKeyAndVisible];
    
    [AMapServices sharedServices].enableHTTPS = YES;
    [AMapServices sharedServices].apiKey = @"988263afc3b7c7710b8ac39bec42f64b";
//    [AMapServices sharedServices].apiKey = @"7d0e03444308fbd66d5697063f65894a";
    //test
    //test
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
}


- (void)applicationWillTerminate:(UIApplication *)application {
}


@end
